#include <iostream>
#include <deque> 

using namespace std;

//deque容器 数据存取

void printDeuque(const deque<int>&d) 
{
    for (deque<int>::const_iterator it = d.begin(); it != d.end(); it++)  //表示只读迭代器
    {
        cout << *it << " ";
    }
    cout << endl;
}

void test07()
{
    deque<int> d1; 

    //尾插
    d1.push_back(10);
    d1.push_back(20);
    d1.push_back(30);

    //头插
    d1.push_front(100);
    d1.push_front(200);
    d1.push_front(300);

    //通过[]方式访问元素
    //
    for (int i = 0; i < d1.size(); i++)
    {
        cout << d1[i] << " ";
    }
    cout << endl;

    //通过at方式访问元素
    for (int i = 0; i < d1.size(); i++)
    {
        cout << d1.at(i) << " ";
    }
    cout << endl;

    cout << "第一个元素为：" << d1.front() << endl;
    cout << "最后一个元素为：" << d1.back() << endl;
}

int main()
{
    test07();

    return 0;
}
